#include "configdialog.h"

ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent)
{
    setupUi(this);

    connect(OkButton,SIGNAL(clicked()),this,SLOT(accept()));
    connect(CancelButton,SIGNAL(clicked()),this,SLOT(reject()));
    connect(BrowserButton,SIGNAL(clicked()),this,SLOT(FileBrowser()));
    connect(linePath,SIGNAL(textChanged(QString)),this,SLOT(IsOkEnabled(QString)));
}



bool ConfigDialog::FileBrowser()
{
    QString dirname=QFileDialog::getExistingDirectory(this,tr("Open Directory"));
    if (dirname==NULL)  return 0;
    linePath->setText(dirname);
    return 1;
}

bool ConfigDialog::IsOkEnabled(QString str)
{
    str+="\\Data";
    QDir dir(str);
    if(dir.exists())
    {
        OkButton->setEnabled(1);
        CancelButton->setEnabled(1);
        return 1;
    }
    else return 0;
}


